#include  <cstdio>
#include  <cstring>

char g[101][101];

void paint(int x, int y, int l, char color)
{
	for( int i = x ; i < x + l ; ++i )
		for( int j = y; j < y + l  ; ++j )
			g[i][j] = color;
}

void test(int x, int y, int l)
{
	int sum = 0;

	for( int i = x ; i < x + l ; ++i )
		for( int j = y; j < y + l  ; ++j )
			if(g[i][j] == 1)
				sum ++;

	printf("%d\n",sum);
}

int main(int argc, char *argv[])
{
	int n,x,y,l;
	char op[10];
	scanf("%d",&n);

	while( n-- )
	{
		scanf("%s%d%d%d",op,&x,&y,&l);
		if(strcmp(op,"BLACK") == 0)
			paint(x,y,l,1);
		else if(strcmp(op,"WHITE") == 0)
			paint(x,y,l,0);
		else
			test(x,y,l);
	}
}

